import { Dexie } from 'dexie';

const blindBoxDB = new Dexie('blindBoxDB');

blindBoxDB.version(1).stores({
  info: ''
})

export default {
  getDB(key = 'userInfo') {
    return blindBoxDB.info.get(key);
  },
  setDB(val, key = 'userInfo') {
    const info = blindBoxDB.info.get(key);
    if (info) {
      blindBoxDB.info.updated(key, val);
    } else {
      blindBoxDB.info.put(val, key);
    }
  },
  delDB(key = 'userInfo') {
    blindBoxDB.info.delete(key);
  }
}